var add=null;
$(function () {
  add=new MapRes();
});
(function(){
  var MapRes = window.MapRes = function(){
    return new MapRes.prototype.init();

  };
  MapRes.fn = MapRes.prototype = {
    urls:{

    },

    init:function () {
      this.initOpt();
      this.initEvent();
      return this;
    },
    initOpt:function () {
      var that=this;
    },
    initEvent:function () {
      var that=this;
      var $pe=$('#mapres');
      /* 单机添加档案归档，跳转到档案归档*/
      $(document).on("click", ".open-popup-settingLayerid", function (e) {
        var title = $(this).data("title");
        var url = $(this).attr("data-url");
        var layerUrl = $("#J_layer_url").val();
        $.getJSON(url, {}, function(data, textStatus) {
          if(textStatus == "success"){
            that.setData($pe, 'setterLayerTree', data);
            setterModal.inputId = "RC_RES_REGISTER_create_form\\:layerId";
            setterModal.selectedItems = $("#RC_RES_REGISTER_create_form\\:layerId").val();
            FM.loadAndShow(setterModal, '设置', actionUrl.settingLayer);
          }
          else{
            MW.alert('服务地址连接失败!');
          }
        });
        parent.layer.open({
          type: 2,
          content:url,
          area:['900px','450px'],
          title:title,
          btn:['确定','取消']
          , yes: function(index,layero){
            //当点击‘确定’按钮的时候，获取弹出层返回的值
            //最后关闭弹出层
            parent.layer.close(index);
          },
        })
        // e.preventDefault();

        // if(layerUrl==""){
        //   layer.msg("请输入服务地址");
        //   return;
        // }
        // var title = $(this).data("title");
        // var url = $(this).attr("data-url")+"/"+layerUrl;
        // window.parent.AddTabs(url,title);
        // AddTabs(url,title);
      });
    },
    setData: function($page,key,value){
      $page.data(key,value);
    },
  };
  MapRes.fn.init.prototype = MapRes.fn;
})();
